Skip to content

Conversation

ChristopherChudzicki
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki commented Jul 22, 2025

What are the relevant tickets?

None

Description (What does it do?)

This adds an env variable to toggle NextJS's image optimization

This PR was made during a production incident when images were returning 502. It turned out to be sporadic 502s not limited to images, but we made this PR to disable image optimization.

Being able to toggle image optimization via an env var seems potentially useful, so making the PR.

How can this be tested?

  1. Run locally with OPTIMIZE_IMAGES=true. Inspect any image on the homepage. Its src should start with _next/, like http://learn.odl.local:8062/_next/image?url=https%3A%2F%2Fprofessional.mit.edu%2Fsites%2Fdefault%2Ffiles%2F2025-01%2FMPE-LNO-ENG-Course_Header-400x400.png&w=640&q=75; note the url=https... part is the raw image url
  2. Run locally with OPTIMIZE_IMAGES=false (or anything else other than true). Image sources should have be raw image url.s

Additional Context

We had some trouble on prod this morning. Turned out not to be due to image optimization.

Still might be useful to have a flag to enable/disable image optimization, so making the PR.

Merge Checklist

@ChristopherChudzicki ChristopherChudzicki changed the title Cc/turn off image optimization Toggle NextJS image optimization with an env var Jul 22, 2025
@shanbady shanbady self-requested a review July 23, 2025 16:57
Copy link
Contributor

@shanbady shanbady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@ChristopherChudzicki ChristopherChudzicki force-pushed the cc/turn-off-image-optimization branch from 3d8491a to 6f1cad6 Compare September 5, 2025 15:29
@ChristopherChudzicki ChristopherChudzicki merged commit 0a746ae into main Sep 5, 2025
13 checks passed
@ChristopherChudzicki ChristopherChudzicki deleted the cc/turn-off-image-optimization branch September 5, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants